home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / UNGETCH.C < prev    next >
Text File  |  1992-11-21  |  1KB  |  47 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef ungetch
  4.  
  5. #ifndef NDEBUG
  6. char *rcsid_ungetch = "$Header: c:/curses/portable/RCS/ungetch.c%v 2.0 1992/11/15 03:29:20 MH Rel $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   ungetch()    - pushes a character back onto the input stream
  15.  
  16.   PDCurses Description:
  17.        There is only one input stream to ungetch characters onto.  It
  18.        is of size NUNGETCH.
  19.  
  20.   PDCurses Return Value:
  21.        The ungetch() routine returns OK upon success otherwise ERR is
  22.        returned.
  23.  
  24.   PDCurses Errors:
  25.        ERR will be returned when the push back stack is full.
  26.  
  27.   Portability:
  28.        PDCurses        ungetch( chtype ch );
  29.        SysV Curses     
  30.        BSD Curses      
  31.  
  32. **man-end**********************************************************************/
  33.  
  34. int    ungetch(chtype ch)
  35. {
  36. extern int     c_pindex;               /* putter index */
  37. extern int     c_gindex;               /* getter index */
  38. extern int     c_ungind;               /* wungetch() push index */
  39. extern chtype  c_ungch[NUNGETCH];      /* array of ungotten chars */
  40.  
  41.        if (c_ungind >= NUNGETCH)       /* pushback stack full */
  42.                return( ERR );
  43.  
  44.        c_ungch[c_ungind++] = ch;
  45.        return( OK );
  46. }
  47.